<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="renderer" content="webkit" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>千锋教育大前端React教学</title>
  <!-- 引入react -->
  <script src="../../lib/js/react.js"></script>
  <!-- 引入react-dom -->
  <script src="../../lib/js/react-dom.js"></script>
  <!-- 引入babel 用来解析jsx -->
  <script src="../../lib/js/babel.js"></script>
  <style>
    .row { display: flex; flex-direction: row; }
    .item { margin-right: 10px; }
  </style>
</head>

<body style="margin:100px;font-size:22px;">
  <!-- 定义一个容器 -->
  <div id="app"></div>
  <script type="text/babel"> /*此处一定要写babel*/
    // 使用js函数返回一个组件
    function App() {
      return [1,2,3,4,5,6,7,8,9].map(i=>(
        <div className='row' key={i}>
          {
            new Array(i).fill().map((o, j)=> {
              j = j + 1;
              return (
                <div className='item' key={j}>
                  { i } x { j } = { i*j }
                </div>
              )
            })
          }
        </div>
      ));
    }
    // 挂载应用
    ReactDOM.createRoot(document.getElementById('app')).render(<App />);
  </script>
</body>

</html>